package com.example.mybatisplus1.conf;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyBatisPlusConfig {

    @Bean
    public MybatisPlusInterceptor mpi(){
        MybatisPlusInterceptor mpi = new MybatisPlusInterceptor();

        //添加mybatisplus的分页插件
        mpi.addInnerInterceptor(new PaginationInnerInterceptor());

        //添加mybatisplus的乐观锁插件
        mpi.addInnerInterceptor(new OptimisticLockerInnerInterceptor());

        return mpi;
    }
}
